#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int N = 2010;


void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<int,int> mp;
    for(int i = 1; i * i < 10100; i += 2){
        mp[i * i]++;
    }
    int ans = 0, sum = 0;
    for(int i = 0; i < n; i++) {
        sum += a[i];
        if(mp[sum]) ans++;
    }
    cout << ans << endl;
}

int main()
{
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}